package com.ruoyi.system.domain.vo;

import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.ruoyi.common.constant.UserConstants;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;


/**
 * @author nanyang
 */
public class PmsArchivesVo implements Serializable {

    @Data
    @ApiModel("PmsArchivesVo - Result")
    public static class Result {
        @ApiModelProperty("id")
        private Long id;
        @ApiModelProperty("姓名")
        private String name;
        @ApiModelProperty("姓名全拼")
        private String pinyinFull;
        @ApiModelProperty("姓名简拼")
        private String pinyinSimple;
        @ApiModelProperty("性别")
        private Byte sex;
        @ApiModelProperty("年龄")
        private Integer age;
        @ApiModelProperty("身份证")
        private String idCard;
        @ApiModelProperty("民族")
        private String nation;
        @ApiModelProperty("联系电话")
        private String phone;
        @ApiModelProperty("身高")
        private String height;
        @ApiModelProperty("体重")
        private String weight;
        @ApiModelProperty("bmi")
        private String bmi;
        //        @ApiModelProperty("更新标识：0第一次输入，1更新患者信息")
//        private Byte status;
        @ApiModelProperty("数据来源")
        private Integer source;
        @ApiModelProperty("档案类型(0:筛查； 1:急救； 2:治疗； 3:康复)")
        private Byte type;
        private String status;

        @ApiModelProperty("备注")
        private String remark;
        @ApiModelProperty("创建者")
        private String createBy;
        @ApiModelProperty(" 创建时间")
        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date createTime;
        @ApiModelProperty("更新者")
        private String updateBy;
        @ApiModelProperty(" 修改时间")
        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date updateTime;
        @ApiModelProperty("档案号")
        private String fileNum;
        @ApiModelProperty("子表数据")
        private List<PmsArchivesRecordVo> recordVoList;
        @ApiModelProperty("dnt")
        private Integer dnt;
        @ApiModelProperty("odt")
        private Integer odt;
        @ApiModelProperty("dit")
        private Integer dit;
        @ApiModelProperty("ont")
        private Integer ont;
        @ApiModelProperty("dpt")
        private Integer dpt;
        @ApiModelProperty("opt")
        private Integer opt;
        @ApiModelProperty("prt")
        private Integer prt;
        private String zdbm;
        private String ssbm;

        private String zyysmc;
        private String ryksmc;
        private String zdmc;

        public String getZllx() {
            if (StrUtil.isNotEmpty(ssbm)) {
                String[] split = ssbm.split(",");
                String str = "";
                for (String s : split) {
                    if (UserConstants.AISJMRS.contains(s)) {
                        str = "AIS静脉溶栓;";
                    }
                    if (UserConstants.AISJRZT.contains(s)) {
                        str += "AIS介入再通;";
                    }
                    if (UserConstants.NCX.contains(s)) {
                        str += "脑出血;";
                    }
                    if (UserConstants.LNDML.contains(s)) {
                        str += "颅内动脉瘤;";
                    }
                    if (UserConstants.CEA.contains(s) || UserConstants.CAS.contains(s)) {
                        str += "CEA/CAS;";
                    }
                }
                return Stream.of(str.split(";")).collect(Collectors.joining(","));
            }

            return null;
        }

    }

    @Data
    @ApiModel("PmsArchivesVo - PmsArchivesRecordVo")
    public static class PmsArchivesRecordVo {
        @ApiModelProperty("key")
        private String code;
        @ApiModelProperty("value")
        private String answer;
        @ApiModelProperty("常规选项")
        private String options;
        @ApiModelProperty("要执行的操作")
        private String operatorName;
        @ApiModelProperty("显示条件")
        private String showType;
        private String codeName;
        private Integer sort = 0;
        @ApiModelProperty("菜单ID")
        private Long codeTagId = 0L;
        private String tagName;
        private String codeTagName;
        @ApiModelProperty("是否异常 0：否； 1：是")
        private Byte isAbnormal = 0;
        @ApiModelProperty("正常取值范围")
        private String normal;
        @ApiModelProperty("是否必填(0：是；1：否)")
        private Byte isMust = 1;

    }


    @Data
    @ApiModel("PmsArchivesVo - Detail")
    public static class Detail {
        @ApiModelProperty("id")
        private Long id;
        @ApiModelProperty("姓名")
        private String name;
        @ApiModelProperty("姓名全拼")
        private String pinyinFull;
        @ApiModelProperty("姓名简拼")
        private String pinyinSimple;
        @ApiModelProperty("性别")
        private Byte sex;
        @ApiModelProperty("年龄")
        private Integer age;
        @ApiModelProperty("身份证")
        private String idCard;
        @ApiModelProperty("民族")
        private String nation;
        @ApiModelProperty("联系电话")
        private String phone;
        @ApiModelProperty("身高")
        private String height;
        @ApiModelProperty("体重")
        private String weight;
        @ApiModelProperty("bmi")
        private String bmi;
        @ApiModelProperty("更新标识：0第一次输入，1更新患者信息")
        private Byte status;
        @ApiModelProperty("数据来源")
        private Integer source;
        @ApiModelProperty("档案类型(0:筛查； 1:急救； 2:治疗； 3:康复)")
        private Byte type;

        @ApiModelProperty("备注")
        private String remark;
        @ApiModelProperty("创建者")
        private String createBy;
        @ApiModelProperty(" 创建时间")
        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date createTime;
        @ApiModelProperty("更新者")
        private String updateBy;
        @ApiModelProperty(" 修改时间")
        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date updateTime;
        @ApiModelProperty("档案号")
        private String fileNum;
        @ApiModelProperty("")
        private List<TagGroup> tagGroupList;
        @ApiModelProperty("子表数据")
        @JsonIgnore
        private List<PmsArchivesRecordVo> recordVoList;
        @ApiModelProperty("dnt")
        private Integer dnt;
        @ApiModelProperty("odt")
        private Integer odt;
        @ApiModelProperty("dit")
        private Integer dit;
        @ApiModelProperty("ont")
        private Integer ont;
        @ApiModelProperty("dpt")
        private Integer dpt;
        @ApiModelProperty("opt")
        private Integer opt;
        @ApiModelProperty("prt")
        private Integer prt;


        @Data
        @ApiModel("菜单数据")
        public static class TagGroup {
            @ApiModelProperty("菜单ID")
            private Long id;
            @ApiModelProperty("菜单名称")
            private String name;
            @ApiModelProperty("子表数据")
            private List<PmsArchivesRecordVo> recordVoList;
        }
    }
}